﻿Imports BusinessLogicLayer
Imports BE = BusinessEntities

Partial Class Editarpais
    Inherits System.Web.UI.Page

    Dim errores As String
    Dim mensaje As String
    Public Shared pais As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

          
            'Recuperamos el parámetro enviado
            pais = Request.QueryString("pais")


            'Instanciamos la clase 
            Dim capanegocios As New PaisBL
            'Instanciamos la entidad de negocio 
            Dim objeto As New BE.PaisBE
            objeto.codigo = pais

            Try
                txtnombre.Text = capanegocios.BuscarPais(objeto). _
                Tables("ElPais").Rows(0).Item(1)

            Catch ex As Exception
                errores = capanegocios.ChapaError
                Response.Redirect("Errores.aspx?id=" & errores)

            Finally
                'Liberamos recursos
                capanegocios = Nothing
                objeto = Nothing
            End Try
        End If



    End Sub



    Protected Sub btngrabar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btngrabar.Click


        'Instanciamos la clase 
        Dim capanegocios As New PaisBL
        'Instanciamos la entidad de negocio 
        Dim objeto As New BE.PaisBE

        objeto.codigo = pais
        objeto.pais = txtnombre.Text

        capanegocios.ActualizarPais(objeto)
        Response.Redirect("MantPaises.aspx")


    End Sub

  
End Class
